﻿/**
 * @file   FITKAbaqusAdaptorPredefinedField.h
 * @brief 预定义场 适配器
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date 2024-07-04
 */
#ifndef __FITKABAQUSADAPTORPREDEFINEDFIELD__H__
#define __FITKABAQUSADAPTORPREDEFINEDFIELD__H__

#include "FITKAbaqusAbstractAdaptor.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include "FITKAbaqusGetInterfaceTool.h"

//前置声明
ForwardDeclarNS(AbaqusData, FITKDataCase)
ForwardDeclarNS(Interface, FITKAbaPredefinedFieldVelocity)
ForwardDeclarNS(Interface, FITKAbaPredefinedFieldTemperature)

namespace IO
{
    /**
     * @brief 预定义场 读写适配器
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date 2024-07-04
     */
    class FITKAbaqusIOINPAPI FITKAbaqusAdaptorPredefinedField : public FITKAbaqusAbstractAdaptor
    {
    public:
        explicit FITKAbaqusAdaptorPredefinedField() = default;
        ~FITKAbaqusAdaptorPredefinedField() = default;

        /**
         * @brief 获取适配器数据类型名
         * @return 适配器数据类型名
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-04
         */
        QString getAdaptorClass() override;

        /**
         * @brief 设置算例数据对象
         * @param[i] caseData
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        void setCaseData(AbaqusData::FITKDataCase* caseData);

        /**
         * @brief 设置关键字所在的行数据
         * @param[i] line 关键字所在的行数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        void setLineKeywords(QString line);

        /**
         * @brief 数据是否为空
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-24
         */
        bool isValueEmpty();

        /**
         * @brief 设置PredefinedField取消激活分析步
         * @param[i] word 关键字
         * @param[i] stepId 分析步id
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-04
         */
        void setPredefinedFieldDeactiveStepR(QString word, int stepId);

        /**
         * @brief 设置写出的数据
         * @param[i] op 关键字op数据
         * @param[i] stepId 分析步id
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-04
         */
        void setWriterData(QString op, int stepId);

         /**
          * @brief 适配器读取
          * @return 状态 true成功， false失败
          * @author liuzhonghua (liuzhonghuaszch@163.com)
          * @date 2024-07-04
          */
        bool adaptR() override;

        /**
         * @brief 适配器写出
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-04
         */
        bool adaptW() override;

    private:
        /**
         * @brief 读取预定义温度场
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-05
         */
        bool readPredefinedFiledTemperature();
        /**
         * @brief 读取预定义速度场
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-05
         */
        bool readPredefinedFiledVelocity();
        /**
         * @brief 写出预定义温度场
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-05
         */
        bool writePredefinedFiledTemperature();
        /**
         * @brief 写出预定义速度场
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-05
         */
        bool writePredefinedFiledVelocity();
    private:
        /**
         * @brief 算例数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-04
         */
        AbaqusData::FITKDataCase* _caseData{};
        /**
         * @brief 获取接口 工具类
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-25
         */
        FITKAbaqusGetInterfaceTool _tool;
        /**
         * @brief 关键字的行
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        QString _keywordsLine{};
        /**
         * @brief 写出分析步id
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-15
         */
        int _stepId{ 0 };
        /**
         * @brief op数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-15
         */
        QString _op{};
        /**
         * @brief 记录数据是否为空
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-24
         */
        bool _isValueEmp{ false };
    };

    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaPredefinedFieldVelocity, FITKAbaqusAdaptorPredefinedField, 1)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaPredefinedFieldTemperature, FITKAbaqusAdaptorPredefinedField, 2)
}

#endif
